package com.ld.poetry;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableAsync
@EnableScheduling
@Slf4j
public class PoetryApplication {

    public static void main(String[] args) {
        // 设置系统编码
        System.setProperty("file.encoding", "UTF-8");
        
        log.info("Starting Poetry Application...");
        log.info("System encoding: {}", System.getProperty("file.encoding"));
        
        ConfigurableApplicationContext context = SpringApplication.run(PoetryApplication.class, args);
        ConfigurableEnvironment env = context.getEnvironment();
        
        log.info("Mail Configuration:");
        log.info("spring.mail.host: {}", env.getProperty("spring.mail.host"));
        log.info("spring.mail.username: {}", env.getProperty("spring.mail.username"));
        log.info("spring.mail.password length: {}", 
            env.getProperty("spring.mail.password") != null ? 
            env.getProperty("spring.mail.password").length() : 0);
        log.info("spring.mail.port: {}", env.getProperty("spring.mail.port"));
        log.info("spring.mail.protocol: {}", env.getProperty("spring.mail.protocol"));
        log.info("spring.mail.default-encoding: {}", env.getProperty("spring.mail.default-encoding"));
        
        log.info("Database Configuration:");
        log.info("spring.datasource.url: {}", env.getProperty("spring.datasource.url"));
        log.info("spring.datasource.username: {}", env.getProperty("spring.datasource.username"));
        log.info("spring.datasource.password length: {}", 
            env.getProperty("spring.datasource.password") != null ? 
            env.getProperty("spring.datasource.password").length() : 0);
    }

}
